<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" >
        <title>体检医院</title>
        <link rel="stylesheet" href="cash-in.css">
        <link rel="stylesheet" href="../public_css/public_header.css">
        <style type="text/css">
            body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
             #allmap{
                height:calc( 100% - 70PX);
                width:100%;
            }
        </style>
    </head>
    <body>

        <header class=" public_header">
            <div class="public_header_return">
                <img src="../public_img/return.png" alt="" class="public_header_return" onclick="history.back(-1)">
                <p>体检医院</p>
            </div>
        </header>
        <div id="allmap"></div>

        <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=HZE4scXysMPZY1HMDTkI4cYSjRo13zZG"></script>
        <script type="text/javascript" src="../public/jquery.min.js"></script>


        <script type="text/javascript">
            $(function () {
                var geolocation = new BMap.Geolocation();
                geolocation.getCurrentPosition(function(r) {
                    var gps_w = r.point.lat;
                    var gps_j = r.point.lng;
                    $.ajax({
                        url:'https://newapp.icandrive.cn/api/hospital.php',
                        type:'post',
                        dataType:'json',
                        success:function(data){
                            var map = new BMap.Map("allmap");
                            map.centerAndZoom(new BMap.Point(gps_j, gps_w), 16);

                            $(data.data).each(function () {

                                var point = new BMap.Point(this.gps_j, this.gps_w);
                                map.centerAndZoom(point, 16);
                                var marker = new BMap.Marker(point);  // 创建标注
                                map.addOverlay(marker);              // 将标注添加到地图中

                                var label = new BMap.Label(this.hos_name,{offset:new BMap.Size(20,-10)});
                                marker.setLabel(label);

                            });
                            var point = new BMap.Point(gps_j, gps_w);
                            map.centerAndZoom(point, 16);
                            var marker = new BMap.Marker(point);  // 创建标注
                            map.addOverlay(marker);               // 将标注添加到地图中
                            marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画

                        },
                        error:function(){

                        }
                    });


                    // 百度地图API功能
                    var map = new BMap.Map("allmap");
                    map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
                    var local = new BMap.LocalSearch(map, {
                        renderOptions:{map: map}
                    });
                    local.searchInBounds("医院", map.getBounds());

                    map.addEventListener("dragend",function(){
                        map.clearOverlays();
                        local.searchInBounds("医院", map.getBounds());
                    });

                })
            });


        </script>


        <script src="../public/jquery.min.js"></script>
        <script>
            document.addEventListener("plusready", function() {
                // 注册返回按键事件
                plus.key.addEventListener('backbutton', function() {
                    window.history.back();
                }, false);
                //此处false代表不退出页面，如果为true回退到上一个一面
            });
        </script>
    </body>
</html>
